<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.welfare.admin.call.*" %>
<%

	HashList code007	= CommonUtil.getCodeList("007", "전체");	//행정동
	HashList code303	= CommonUtil.getCodeList("303", "전체");	//세대구분
	HashList code304	= CommonUtil.getCodeList("304", "전체");	//보장구분
	
	
	HashBox box = new HashBox(request);

	String s_customer_name		= StringUtil.nvl(request.getParameter("s_customer_name"));
	String s_birth_date			= StringUtil.nvl(request.getParameter("s_birth_date"));
	String s_tel_no				= StringUtil.nvl(request.getParameter("s_tel_no"));
	String s_hp_no				= StringUtil.nvl(request.getParameter("s_hp_no"));
	String s_dong_code			= StringUtil.nvl(request.getParameter("s_dong_code"));
	String s_family_gubn		= StringUtil.nvl(request.getParameter("s_family_gubn"));
	String s_support_gubn		= StringUtil.nvl(request.getParameter("s_support_gubn"));
	String s_remarks			= StringUtil.nvl(request.getParameter("s_remarks"));
	String s_from_birth_date	= StringUtil.nvl(request.getParameter("s_from_birth_date"));
	String s_to_birth_date		= StringUtil.nvl(request.getParameter("s_to_birth_date"));
	
	String curr_page 			= StringUtil.nvl(request.getParameter("curr_page"), "1");
	String sort_col				= StringUtil.nvl(request.getParameter("sort_col"), "to_number(customer_id)");
	String sort_asc				= StringUtil.nvl(request.getParameter("sort_asc"), "desc");


	HashMap infos = new HashMap();
	infos.put("customer_name",		s_customer_name);
	infos.put("birth_date",			s_birth_date);
	infos.put("tel_no",				s_tel_no);
	infos.put("hp_no", 				s_hp_no);
	infos.put("dong_code",			s_dong_code);
	infos.put("family_gubn",		s_family_gubn);
	infos.put("support_gubn",		s_support_gubn);
	infos.put("remarks", 			s_remarks);
	infos.put("from_birth_date", 	s_from_birth_date);
	infos.put("to_birth_date",		s_to_birth_date);
	
	//paging
	infos.put("line_per_page",	"10");	
	infos.put("curr_page",		curr_page);
	infos.put("sort_col", 		sort_col);
	infos.put("sort_asc", 		sort_asc);
 
	CallDAO dao 	= new CallDAO();
	HashList list 	= dao.selectCustomerList(infos);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= SYSTEM_NAME %> 관리자</title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#s_customer_name').focus().select();
		$('#list').find('tr').hover(
				function () { $(this).addClass("hover"); }
			  , function () { $(this).removeClass("hover"); }
			)
			.click(function(){
				var customerId = $(this).find('.customer_id').text();
				cfOpen('customerInfo.jsp?customer_id=' + customerId, 'customer'+$.trim(customerId), 720, 420);
			});
		
		
		$('.sort').on('click', function() {
			document.searchForm.sort_col.value = $(this).attr('id');
			document.searchForm.sort_asc.value = 'asc';
			document.searchForm.submit();
		});
		

		$('.asc').on('click', function() {
			document.searchForm.sort_col.value = $(this).attr('id');
			document.searchForm.sort_asc.value = 'desc';
			document.searchForm.submit();
		});
		
		$('.desc').on('click', function() {
			document.searchForm.sort_col.value = '';
			document.searchForm.sort_asc.value = '';
			document.searchForm.submit();
		});
	});


	function fnSearch(currPage) {
		$('#searchForm').attr('action', './customerList.jsp?curr_page=' + currPage);
		$('#searchForm').submit();
	}

	function fnExcel() {
		$('#searchForm').attr('action', './customerExcel.jsp');
		$('#searchForm').submit();
		$('#searchForm').attr('action', './customerList.jsp');
	}
	
	function fnCallBackSearch() {
		fnSearch(1);
	}
	</script>
</head>
<body>
<div id="wrap">
	<div id="page">
		<div id="contents_nowidth">
			<div class="menu_title">
				<h1>고객리스트</h1>
				<p>관리자 > 콜센터 > <b>고객리스트</b></p>
			</div>
			<div class="clear line_01"></div>

			<form name="searchForm" id="searchForm" method="post" action="./customerList.jsp">
			<input type="hidden" name="sort_col" value="<%= sort_col %>"/>
			<input type="hidden" name="sort_asc" value="<%= sort_asc %>"/>
			
			<table cellpadding="0" cellspacing="0" class="table_01 mt15">
			<colgroup>
				<col width="100px" />
				<col width="200px" />
				<col width="100px" />
				<col width="200px" />
				<col width="100px" />
				<col  />
			</colgroup>
			<tbody id="search">
				<tr>
					<th><p>행정동</p></th>
					<td>
						<select name="s_dong_code" class="w120">
						<%= StringUtil.makeOption(code007, s_dong_code) %>
						</select>
					</td>
					<th><p>세대구분</p></th>
					<td>
						<select name="s_family_gubn" class="w120">
						<%= StringUtil.makeOption(code303, s_family_gubn) %>
						</select>
					</td>
					<th><p>보장구분</p></th>
					<td class="brx">
						<select name="s_support_gubn" class="w120">
						<%= StringUtil.makeOption(code304, s_support_gubn) %>
						</select>
					</td>
				</tr>
				<tr>
					<th><p>이름</p></th>
					<td>
						<input type="text" name="s_customer_name" id="s_customer_name" value="<%= s_customer_name %>" class="w120"/>
					</td>
					<th><p>생년월일</p></th>
					<td>
						<input type="text" name="s_birth_date" value="<%= s_birth_date %>" class="w120"/>
					</td>
					<th><p>비고</p></th>
					<td class="brx">
						<input type="text" name="s_remarks" value="<%= s_remarks %>" class="w120"/>
					</td>
				</tr>
				<tr>
					<th><p>전화번호</p></th>
					<td>
						<input type="text" name="s_tel_no" value="<%= s_tel_no %>" class="w120"/>
					</td>
					<th><p>핸드폰번호</p></th>
					<td>
						<input type="text" name="s_hp_no" value="<%= s_hp_no %>" class="w120"/>
					</td>
					<th><p>연령대</p></th>
					<td class="brx">
						<input type="text" name="s_from_birth_date" value="<%= s_from_birth_date %>" class="w70" maxlength="8"/>
						~
						<input type="text" name="s_to_birth_date" value="<%= s_to_birth_date %>" class="w70" maxlength="8"/>
					</td>
				</tr>
			</tbody>
			</table>
			

			<div class="mt10 mb10 r">
				<input type="image" class="button" src="../images/btn_search.gif"/>
				<a href="#nohref" onclick="document.searchForm.reset()"><img src="../images/btn_init.gif"/></a>
				<a href="#nohref" onclick="fnExcel()"><img src="../images/btn_excel.gif"/></a>
			</div>

			</form>



			<div class="search_result">검색결과 : <%= StringUtil.toPrice((String)infos.get("total_count")) %>건</div>

		    <table width="100%" cellpadding="0" cellspacing="0" class="table_04">
				<colgroup>
					<col width="60px"/>
					<col width="100px"/>
					<col width="50px"/>
					<col width="80px"/>
					<col width="100px"/>
					<col width="100px"/>
					<col width="100px"/>
					<col width="100px"/>
					<col width="80px"/>
					<col width="100px"/>
					<col width="80px"/>
					<col />
					<col width="100px"/>
				</colgroup>
				<thead>
					<tr> 
						<th><p>번호</p></th>
						<th class="<%= "customer_name".equals(sort_col) ? sort_asc : "sort" %>" id="customer_name"><p>이름</p></th>
						<th class="<%= "gender".equals(sort_col) ? sort_asc : "sort" %>" id="gender"><p>성별</p></th>
						<th class="<%= "birth_date".equals(sort_col) ? sort_asc : "sort" %>" id="birth_date"><p>생년월일</p></th>
						<th class="<%= "tel_no".equals(sort_col) ? sort_asc : "sort" %>" id="tel_no"><p>전화번호</p></th>
						<th class="<%= "hp_no".equals(sort_col) ? sort_asc : "sort" %>" id="hp_no"><p>핸드폰번호</p></th>
						<th class="<%= "dong_code".equals(sort_col) ? sort_asc : "sort" %>" id="dong_code"><p>행정동</p></th> 
						<th class="<%= "family_gubn".equals(sort_col) ? sort_asc : "sort" %>" id="family_gubn"><p>세대구분</p></th>
						<th class="<%= "family_count".equals(sort_col) ? sort_asc : "sort" %>" id="family_count"><p>가구원수</p></th>
						<th class="<%= "support_gubn".equals(sort_col) ? sort_asc : "sort" %>" id="support_gubn"><p>보장구분</p></th>
						<th class="<%= "counsel_count".equals(sort_col) ? sort_asc : "sort" %>" id="counsel_count"><p>상담건수</p></th>
						<th class="<%= "remarks".equals(sort_col) ? sort_asc : "sort" %>" id="remarks"><p>비고</p></th>
						<th class="c <%= "mod_date".equals(sort_col) ? sort_asc : "sort" %>" id="mod_date"><p>최종수정일</p></th>
					</tr>
				</thead>
				<tbody id="list">
			<%	for (int i = 0; i < list.size(); i++) { %>
					<tr>
						<td class="customer_id">
							<%= list.get("customer_id", i) %>
						</td>
						<td><%= list.get("customer_name", i) %></td>
						<td><%= list.get("gender", i) %></td>
						<td><%= list.get("birth_date", i) %></td>
						<td><%= list.get("tel_no", i) %></td>
						<td><%= list.get("hp_no", i) %></td>
						<td><%= list.get("dong_code", i) %></td>
						<td><%= list.get("family_gubn", i) %></td>
						<td><%= list.get("family_count", i) %></td>
						<td><%= list.get("support_gubn", i) %></td>
						<td><%= list.get("counsel_count", i) %></td>
						<td class="l"><%= list.get("remarks", i) %></td>
						<td><%= list.getDate("mod_date", i) %></td>
					</tr>
			<%	} %>
				</tbody>
			</table>
			
			<div class="pagination">
				<%= StringUtil.getPageHtml(infos) %>
			</div>

		</div>
	</div>
</div>
</body>
</html>
